package com.cskaoyan.javase.oop3._3local._2usecase;

/**
 * 使用内部类来实现真正意义上的多继承
 *
 * @since 15:15
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Demo2 {
    public static void main(String[] args) {
        C c = new C();
        c.test();
    }
}

class B {
    // 用内部类实现多继承
    public void method() {
        PersonSon p = new PersonSon();
        p.test();
        StudentSon s = new StudentSon();
        s.test2();
        TeacherSon t = new TeacherSon();
        t.test3();
    }

    class PersonSon extends Person {
    }

    class StudentSon extends Student {
    }

    class TeacherSon extends Teacher {
    }
}

class Person {
    void test() {
    }
}

class Student {
    void test2() {
    }
}

class Teacher {
    void test3() {
    }
}

// 用接口配合Java8中默认实现方法也可以实现多继承
class C implements IB, IC, ID {

}

interface IB {
    default void test() {
    }
}

interface IC {
    default void test2() {
    }
}

interface ID {
    default void test3() {
    }
}